package com.jumi.microservice.domain;

import com.jumi.microservice.common.base.AbstractObject;
import com.jumi.microservice.constant.ExceptionEnum;
import com.jumi.microservice.domain.FreightTemplateExtendVO;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 * 运费模板表
 * </p>
 *
 * @author liuz
 * @since 2020-07-27
 */
public class FreightTemplateDTO extends AbstractObject implements Serializable {

    private static final long serialVersionUID = 1L;

    private Long id;

    private Integer rule;

    private String templateName;

    private LocalDateTime createTime;

    private String creater;

    private String modifier;

    private LocalDateTime updateTime;

    List<FreightTemplateExtendVO> freightTemplateExtendVO;


    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getTemplateName() {
        return templateName;
    }

    public void setTemplateName(String templateName) {
        this.templateName = templateName;
    }

    public LocalDateTime getCreateTime() {
        return createTime;
    }

    public void setCreateTime(LocalDateTime createTime) {
        this.createTime = createTime;
    }

    public List<FreightTemplateExtendVO> getFreightTemplateExtend() {
        return freightTemplateExtendVO;
    }

    public void setFreightTemplateExtend(List<FreightTemplateExtendVO> freightTemplateExtend) {
        this.freightTemplateExtendVO = freightTemplateExtend;
    }

    public String getCreater() {
        return creater;
    }

    public void setCreater(String creater) {
        this.creater = creater;
    }

    public String getModifier() {
        return modifier;
    }

    public void setModifier(String modifier) {
        this.modifier = modifier;
    }

    /**
     * 转化获取pos
     * @return
     */
    public List<FreightTemplateExtendDO> getPos(){
        List<FreightTemplateExtendDO> list = null;
        if(this.freightTemplateExtendVO!=null&&this.freightTemplateExtendVO.size()>0){
            list = this.freightTemplateExtendVO.stream().map(p->{
                FreightTemplateExtendDO po = null;
                try {
                    po = p.clone(FreightTemplateExtendDO.class);
                }catch (Exception e){
                    ExceptionEnum.FAIL_CHANGE.newException();
                }
                return po;
            }).collect(Collectors.toList());
        }
        return list;
    }

    public LocalDateTime getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(LocalDateTime updateTime) {
        this.updateTime = updateTime;
    }

    public Integer getRule() {
        return rule;
    }

    public void setRule(Integer rule) {
        this.rule = rule;
    }
}
